program PROB010;
var
  p : array[1..1000] of longint;
  i, l : longint;
  sum : extended;

function prime(k : longint) : boolean;
var
  i, c : longint;
begin
  prime := false;
  c := trunc(sqrt(k));
  for i := 1 to l do
  begin
    if p[i] > c then break;
    if k mod p[i] = 0 then exit;
  end;
  prime := true;
end;

begin
  sum := 0;

  for i := 2 to 1000 do
    if prime(i) then
    begin
      inc(l);
      p[l] := i;
      sum := sum + i;
    end;

  for i := 1001 to 1000000 do
    if prime(i) then sum := sum + i;

  writeln(sum:0:0);
end.